package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.Book_Deal;

@WebServlet("/BookPut")
public class BookPut extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private Book_Deal deal = new Book_Deal();
    public BookPut() {
        super();
    }

	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		res.setCharacterEncoding("utf-8");
		String order_id = req.getParameter("order_id");
		String book_imgsrc = req.getParameter("book_imgsrc");
		String book_id = req.getParameter("book_id");
		String book_name = req.getParameter("book_name");
		String typeName = req.getParameter("typeName");
		String author = req.getParameter("author");
		String press_name = req.getParameter("press_name");
		String put_number = req.getParameter("put_number");
		
		boolean falg = deal.book_put(order_id, book_imgsrc,book_id,book_name,typeName,author,press_name,put_number);
		if(falg) {
			res.sendRedirect("/TeachingTest/main?page=book-put&target=3");
		}else {
			res.sendRedirect("/TeachingTest/main?page=book-put&target=3");
		}
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		doGet(req, res);
	}

}
